syntax = "proto3";

package blog_auth.v1;

option go_package = './proto';

import "google/api/annotations.proto";
import "validate/validate.proto";

service AuthApi {
  rpc Register(InputRegisterLogin) returns (ResponseData) {
    option (google.api.http) = {
      post: "/register"
      body: "*"
    };
  }
  rpc Login(InputRegisterLogin) returns (ResponseData) {
    option (google.api.http) = {
      post: "/login"
      body: "*"
    };
  }
  rpc Logout(InputLogoutRefresh) returns (ResponseLogoutData) {
    option (google.api.http) = {
      post: "/logout"
      body: "*"
    };
  }
  rpc Refresh(InputLogoutRefresh) returns (ResponseData) {
    option (google.api.http) = {
      post: "/refresh"
      body: "*"
    };
  }
}

message InputRegisterLogin {
  string email = 1 [(validate.rules).string.email = true];
  string password = 2 [(validate.rules).string = {min_len: 6, max_len: 150}];
}

message InputLogoutRefresh {
  string refreshToken = 1;
}

message ResponseData {
  string accessToken = 1;
  string refreshToken = 2;
  string userId = 3;
}

message ResponseLogoutData {
  string refreshToken = 1;
}

